window.addEventListener('load', function () {
    var rgtel = /^1[3|5|6|7|8|9]\d{9}$/
    var rgqq = /^[1-9]\d{4,}/
    var rgnc = /^[\u4e00-\u9fa5]{2,8}$/
    var rgmsg = /^\d{6}$/
    var rgpass = /^[a-zA-Z0-9_-]{6,16}$/
    var rgkg = /^[.\n]+$/
    var tel = document.querySelector('#tel')
    var qq = document.querySelector('#qq')
    var nc = document.querySelector('#nc')
    var msg = document.querySelector('#msg')
    var pass = document.querySelector('#pass')
    var passyesno = document.querySelector('#passyesno')
    regexp(tel, rgtel)
    regexp(qq, rgqq)
    regexp(nc, rgnc)
    regexp(msg, rgmsg)
    regexp(pass, rgpass)
    function regexp(ele, rge) {
        ele.onblur = function () {
            if (rge.test(this.value)) {
                this.nextElementSibling.className = 'success'
                this.nextElementSibling.innerHTML = '<i class="success_icon"></i>输入正确'
            } else {
                this.nextElementSibling.className = 'error'
                this.nextElementSibling.innerHTML = '<i class="error_icon"></i>格式错误'
            }
        }
    }
    passyesno.onblur = function () {
        if (this.value == '') {
            this.nextElementSibling.className = 'error'
            this.nextElementSibling.innerHTML = '<i class="error_icon"></i>密码不能为空'
        }
        else if (this.value == pass.value) {
            this.nextElementSibling.className = 'success'
            this.nextElementSibling.innerHTML = '<i class="success_icon"></i>输入正确'
        } else {
            this.nextElementSibling.className = 'error'
            this.nextElementSibling.innerHTML = '<i class="error_icon"></i>密码与上次不否'
        }
    }
})